package com.house.controller;

import com.house.pojo.HouseProduct;
import com.house.service.IHouseProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/houseProduct")
/**
 * 22001011032刘晓妍
 */
public class HouseProductController {
    @Autowired
    private IHouseProductService service;
    @GetMapping
    public List<HouseProduct> list(){
        return service.list();
    }
    @GetMapping("/{id}")
    public HouseProduct getInfo(@PathVariable Integer id) {
        return service.getById(id);
    }
    @PostMapping
    public Integer add(@RequestBody HouseProduct houseProduct){
        if (houseProduct.getName()==null){
            return 0;
        }
        return service.add(houseProduct);
    }
    @PutMapping
    public Integer update(@RequestBody HouseProduct houseProduct){
        return service.update(houseProduct);
    }
    @DeleteMapping("/{id}")
    public Integer delete(@PathVariable Integer id){
        return service.delete(id);
    }
}
